//
//  HomeViewController.m
//  CrazyRiddle
//
//  Created by mac on 2017/9/18.
//  Copyright © 2017年 上海LOL信息技术服务有限公司. All rights reserved.
//

#import "HomeViewController.h"
#import "MainViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}


#pragma mark --- Action
-(void)startGameButton{
    // 开始游戏
    MainViewController *main = [[MainViewController alloc]init];
    [self.navigationController pushViewController:main animated:YES];
}

-(void)shopButtonClick{
    // 购物
}

-(void)musicButtonClick:(UIButton *)sender{
    // 音乐
}



#pragma mark ---

-(void)setupUI{
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    UIImageView *backImageView = [[UIImageView alloc]init];
    backImageView.image = [UIImage imageNamed:@"sky.png"];
    [self.view addSubview:backImageView];
    [backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    UIImageView *meadowImageView = [[UIImageView alloc]init];
    meadowImageView.image = [UIImage imageNamed:@"meadow.png"];
    [self.view addSubview:meadowImageView];
    [meadowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.view);
        make.height.mas_equalTo(self.view.height/5*3);
    }];
    
    UIImageView *treeImageView = [[UIImageView alloc]init];
    treeImageView.image = [UIImage imageNamed:@"tree.png"];
    [self.view addSubview:treeImageView];
    [treeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(20);
        make.bottom.equalTo(self.view).offset(-20);
        make.width.mas_equalTo(@51);
        make.height.mas_equalTo(@94);
    }];
    
    UIImageView *moleImageView = [[UIImageView alloc]init];
    moleImageView.image = [UIImage imageNamed:@"mole.png"];
    [self.view addSubview:moleImageView];
    [moleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-10);
        make.width.mas_equalTo(@24);
        make.height.mas_equalTo(@34);
    }];
    
    UIImageView *millImageView = [[UIImageView alloc]init];
    millImageView.image = [UIImage imageNamed:@"mill.png"];
    [self.view addSubview:millImageView];
    [millImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view).offset(-20);
        make.bottom.equalTo(self.view).offset(-30);
        make.width.mas_equalTo(@23);
        make.height.mas_equalTo(@39);
    }];

    UIImageView *iconImageView = [[UIImageView alloc]init];
    iconImageView.image = [UIImage imageNamed:@"bigicon.png"];
    [self.view addSubview:iconImageView];
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(@115);
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.view).offset(70);
    }];
    
    UIImageView *titleImageView = [[UIImageView alloc]init];
    titleImageView.image = [UIImage imageNamed:@"title_cn.png"];
    [self.view addSubview:titleImageView];
    [titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(@234);
        make.height.mas_equalTo(@50);
        make.centerX.equalTo(self.view);
        make.top.equalTo(iconImageView.mas_bottom).offset(70);
    }];
    
    UIButton *startButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [startButton setImage:[UIImage imageNamed:@"start_cn.png"] forState:UIControlStateNormal];
    [startButton addTarget:self action:@selector(startGameButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:startButton];
    [startButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(titleImageView.mas_bottom).offset(50);
        make.width.mas_equalTo(194);
        make.height.mas_equalTo(61);
    }];
    
    UIButton *shopButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [shopButton setImage:[UIImage imageNamed:@"board.png"] forState:UIControlStateNormal];
    [shopButton addTarget:self action:@selector(shopButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:shopButton];
    [shopButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(treeImageView);
        make.top.equalTo(treeImageView).offset(10);
        make.width.mas_equalTo(54);
        make.height.mas_equalTo(36);
    }];
    
    
    UIButton *musicButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [musicButton setImage:[UIImage imageNamed:@"btn_music_on.png"] forState:UIControlStateNormal];
    [musicButton addTarget:self action:@selector(musicButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:musicButton];
    [musicButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view).offset(-20);
        make.top.equalTo(self.view).offset(30);
        make.width.height.mas_equalTo(36);
    }];

    

    

}



@end
